package com.z.pms1.action;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.Action;
import com.z.pms1.service.LoginService;

/**
 * @Title: handle login request
 * @Description:
 * @Copyright: z 2013
 * @Date: Jan 24, 2013 4:45:54 PM
 * @author: caizhen
 * @version: 1.0
 */
public class LoginAction extends BaseAction{
	
	protected static final Log log = LogFactory.getLog(LoginAction.class.getName());
	
	@Autowired
	private LoginService loginService;
	
	private String user_id;
	
	private String passwd;
	
	public String login() {
		System.out.println(">>>>>>>>>>>>>>");
		System.out.println(user_id + ":" + passwd);
		log.info(user_id + ":" + passwd);
		boolean succ = loginService.login(user_id, passwd);
		if (!succ) {
			return Action.ERROR;
		}
		this.getSession().put("user_id", user_id);
		return Action.SUCCESS;
	}
	
	public String getUser_id() {
		return user_id;
	}

	public void setUser_id(String user_id) {
		this.user_id = user_id;
	}

	public String getPasswd() {
		return passwd;
	}

	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}
	
}
